#include <STC89C5xRC.H>
#include "delay.h"
#include "LCD1602.h"
#include "timer0.h"

unsigned char Sec,Min,Hour;
void main()
{
	LCD_Init();
	time0_init();
	LCD_ShowString(1,1,"Clock:");
	LCD_ShowString(2,1,"  :  :");
	while(1)
	{
		LCD_ShowNum(2,1,Hour,2);
		LCD_ShowNum(2,4,Min,2);
		LCD_ShowNum(2,7,Sec,2);
	}


}

void timer0_routine() interrupt 1
{
	static unsigned int t0count;
	TH0=64535/256;
	TL0=64535%256;
	t0count++;
	if(t0count>=1000)
	{
		t0count = 0;
		Sec++;
		if(Sec>=60)
		{
			Sec=0;
			Min++;
			if(Min>=60)
			{
				Min=0;
				Hour++;
				if(Hour>=24)
				{
					Hour=0;
				}
			}
		}
	}
}
